package com.kurumi.util;

import java.math.BigDecimal;

public class NumberUtils {

	public static BigDecimal getPrecent(BigDecimal number, BigDecimal total){
		if(total.compareTo(BigDecimal.ZERO) <=0 || number.compareTo(BigDecimal.ZERO) <=0){
			return BigDecimal.ZERO;
		}
		return number.multiply(new BigDecimal("100")).divide(total,2,BigDecimal.ROUND_HALF_UP);
	}
	
	public static String getString(BigDecimal number,int scale){
		return number.setScale(scale, BigDecimal.ROUND_HALF_UP).toString();
	}
	/*public static void main(String[] args) {
		System.err.println(getPrecent(new BigDecimal("0"), new BigDecimal("2")));
		System.err.println(getString(new BigDecimal("3333.335"),2));
	}*/
}
